package com.chonglie;

import com.chonglie.calc.CalcActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.PopupWindow;

public class HelloAndroidActivity extends Activity {
	public static final String EXTRA_MESSAGE = "extra_message";

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}

	@Override
	protected void onStart() {
		super.onStart();

	}

	public void sendMessage(View view) {
		Intent intent = new Intent(this, DisplayMessageActivity.class);
		EditText editText = (EditText) findViewById(R.id.edit_message);
		intent.putExtra(EXTRA_MESSAGE, editText.getText().toString());
		startActivity(intent);
	}

	public void showHelloWorld(View view) {
		Intent intent = new Intent(this, HelloWorldActivity.class);
		startActivity(intent);
	}

	public void showListView(View view) {
		Intent intent = new Intent(this, ListViewActivity.class);
		startActivity(intent);
	}

	public void showGridView(View view) {
		Intent intent = new Intent(this, GridViewActivity.class);
		startActivity(intent);
	}

	public void showAlertDialog(View view) {
		Intent intent = new Intent(this, AlertDialogActivity.class);
		startActivity(intent);
	}

	public void showPopupWindow(View view) {

		LayoutInflater inflater = LayoutInflater.from(this);

		final View popupWindowView = inflater.inflate(R.layout.popup_window,
				null);
		final PopupWindow pw = new PopupWindow(popupWindowView, 500, 500, true);

		Button btnConfirm = (Button) popupWindowView
				.findViewById(R.id.popupwindow_confirm);

		btnConfirm.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				EditText nameText = (EditText) popupWindowView
						.findViewById(R.id.popupwindow_name);
				EditText pswdText = (EditText) popupWindowView
						.findViewById(R.id.popupwindow_pswd);

				setTitle(nameText.getText() + "," + pswdText.getText());
			}
		});

		Button btnCancel = (Button) popupWindowView
				.findViewById(R.id.popupwindow_cancel);
		btnCancel.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				pw.dismiss();
			}
		});

		pw.showAtLocation(view, Gravity.CENTER, 0, 200);
	}

	public void showTab(View view) {
		Intent intent = new Intent(this, TestTabActivity.class);
		startActivity(intent);
	}

	public void showGallery(View view) {
		Intent intent = new Intent(this, GalleryActivity.class);
		startActivity(intent);
	}

	public void showImageSwitcher(View view) {
		Intent intent = new Intent(this, ImageSwitcherActivity.class);
		startActivity(intent);
	}

	public void showDrawable(View view) {
		Intent intent = new Intent(this, DrawableActivity.class);
		startActivity(intent);
	}

	public void showMediaPlayer(View view) {
		Intent intent = new Intent(this, MediaPlayerActivity.class);
		startActivity(intent);
	}

	public void showDrawCurve(View view) {
		Intent intent = new Intent(this, SurfaceViewActivity.class);
		startActivity(intent);
	}

	public void showGif(View view) {
		Intent intent = new Intent(this, GifActivity.class);
		startActivity(intent);
	}

	public void showActivityLifecycle(View view) {
		Intent intent = new Intent(this, ActivityLifecycleActivity1.class);
		startActivity(intent);
	}

	public void showServLifecycle(View view) {
		Intent intent = new Intent(this, ServLifecycleActivity.class);
		startActivity(intent);
	}

	public void showBroadcastReceiver(View view) {
		Intent intent = new Intent(this, BroadcastReceiverActivity.class);
		startActivity(intent);
	}

	public void showParserXML(View view) {
		Intent intent = new Intent(this, ParserXmlActivity.class);
		startActivity(intent);
	}

	public void showCalcActivity(View view) {
		Intent intent = new Intent(this, CalcActivity.class);
		startActivity(intent);
	}
}